package com.example.demo.paper.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.exception.ZException;
import com.example.demo.paper.entity.TPaper;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 试卷表 服务类
 * </p>
 *
 * @author zhongz
 * @since 2019-02-16
 */
public interface ITPaperService extends IService<TPaper> {

    /**
     * 获取列表
     *
     * @param pagination 页码
     * @param size       每页显示
     * @return
     */
    IPage<Map<String, Object>> getList(Integer pagination, Integer size);

    /**
     * 获取试卷详情
     *
     * @param paperId 试卷id
     * @return
     */
    List<Map<String, Object>> getDetail(String paperId) throws ZException;

    /**
     * 提交试卷
     *
     * @param paperId    试卷id
     * @param records    答题记录
     * @param rightCount 正确数
     * @param wrongCount 错误数
     * @param spendTime  花费时间
     * @return
     */
    Boolean finishPaper(String paperId, String records, Integer rightCount, Integer wrongCount,
                        @RequestParam(required = false) Integer spendTime) throws Exception;

    /**
     * 缓存回答试卷数据
     *
     * @param paperId 试卷id
     * @param records 试卷数据
     */
    void cachePaper(String paperId, String records);
}
